Skip to content

Conversation

@dustinbyrne
Copy link
Contributor

@dustinbyrne dustinbyrne commented Feb 5, 2026

💡 Motivation and Context

Add a getFeatureFlagResult API that returns a unified PostHogFeatureFlagResult object containing the flag key, enabled state, variant (for multivariate flags), and payload in a single call. Previously, getting full flag information required separate calls to getFeatureFlag and getFeatureFlagPayload. This also supports a sendEvent parameter to suppress the $feature_flag_called event when only the payload is needed.

getFeatureFlagPayload is now deprecated in favor of this new method.

💚 How did you test it?

  • Added unit tests for PostHogFeatureFlagResult (fromValueAndPayload, fromMap, equality, toString, null/edge cases)
  • Added integration tests via a fake platform interface covering boolean flags, multivariate flags, payloads, null values, and sendEvent parameter forwarding
  • Updated the example app to exercise getFeatureFlagResult
  • Manually verified native Android and iOS implementations serialize the result map correctly via method channels

📝 Checklist

  • I reviewed the submitted code.
  • I added tests to verify the changes.
  • I updated the docs if needed.
  • No breaking change or entry added to the changelog.

@dustinbyrne dustinbyrne requested a review from a team as a code owner February 5, 2026 18:38
@dustinbyrne dustinbyrne force-pushed the feat/get-feature-flag-result branch from 6458f44 to 7bf8fa6 Compare February 5, 2026 18:40
@dustinbyrne
Copy link
Contributor Author

CI will fail until PostHog/posthog-ios#459 is released

@dustinbyrne dustinbyrne changed the title feat: Add getFeatureFlagPayload API feat: Add getFeatureFlagResult API Feb 5, 2026
@dustinbyrne dustinbyrne force-pushed the feat/get-feature-flag-result branch from 7bf8fa6 to 483265d Compare February 5, 2026 19:03
other.key == key &&
other.enabled == enabled &&
other.variant == variant &&
other.payload == payload;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is not doing deep equality, should we?
you can check PHListEquality().equals(...) if payload is a collection

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've opted to pull the payload out of the equals and hashCode implementations. I'm not sure there's a real use case for comparing these, but key / enabled / variant would likely be enough.

Copy link
Member

@marandaneto marandaneto left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

left a few comments otherwise LGTM

I'm not certain what the use case is to compare feature flag results, so
I don't think it's worth deep comparing the result. Maybe we'll get
feedback on this in the future and reconsider.
@dustinbyrne dustinbyrne merged commit fcd46ba into main Feb 10, 2026
16 checks passed
@dustinbyrne dustinbyrne deleted the feat/get-feature-flag-result branch February 10, 2026 14:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants